Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WiP] Selecting multiple files for deleting on left menu #368

Closed
wants to merge 6 commits into from

Conversation

guergana
Copy link
Collaborator

@guergana guergana commented May 5, 2024

@guergana guergana marked this pull request as draft May 5, 2024 15:31
Copy link

cloudflare-workers-and-pages bot commented May 6, 2024

Deploying opendataeditor with  Cloudflare Pages  Cloudflare Pages

Latest commit: f0a32f0
Status: ✅  Deploy successful!
Preview URL: https://75fad6b3.opendataeditor.pages.dev
Branch Preview URL: https://341-selecting-multiple-files.opendataeditor.pages.dev

View logs

@guergana guergana force-pushed the 341-selecting-multiple-files-menu branch from 9f0f583 to 2b23a80 Compare June 2, 2024 11:15
return (
<InputDialog
open={true}
value={path}
value={paths[0]}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how moving file works. This might need to be reworked as well for multiple files

return (
<InputDialog
open={true}
value={path}
value={paths[0]}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as with moving files. This might need to be adjusted for multiSelection

for (const path of paths) {
await client.fileDelete({ path })
onFileDelete(path)
}
},
moveFile: async (path, toPath) => {
const { client, onFileCreate } = get()
const result = await client.fileMove({ path, toPath, deduplicate: true })
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how this works. haven't tested it yet

if (paths === newPaths) return
set({ paths: newPaths })
if (!newPaths) return
if (record?.path === newPaths[0]) return
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what this is doing. using only the first path just in case. Is it for the history? Do we need to modify the record to add all the selected paths?

if (selectors.isFolder(get())) return
await openFile(newPath)
// if more than one file is selected, display the only the first one
if (paths && paths[0] !== newPaths[0]) await openFile(newPaths[0])
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still not working 😅

@guergana
Copy link
Collaborator Author

guergana commented Jun 7, 2024

@roll I need your help with this PR. I have some issues I can't figure out on my own, besides the fact that I am changing parts of the application in this ticket that I am not sure which side effects they could have..

I don't understand why here: https://github.com/okfn/opendataeditor/blob/main/client/components/Application/Content.tsx#L28 ? the FileContent is updated and fired even if the client and the record stay the same. If you test, when you select one File in the left menu it loads correctly, but when you select a second file, in theory, the FileContent component should stay the same, but it updates and returns a blank screen. Could you help me debug and test since you are the most familiar with all parts of the application? 🙏

@guergana guergana requested a review from roll June 7, 2024 10:01
@roll
Copy link
Collaborator

roll commented Jun 10, 2024

@guergana
@pdelboca
As we don't yet have tests for this store, and the complexity is already very high, I think the safest approach here would be to introduce a completely new state property like secondaryPaths with completely separated logic that only works for selection and deleting (the user story requirement), for example:

  • on file click we set path='file1'
  • on ctrl-click on other file we set secondaryPaths=['file2']
  • [handling selecting / deselecting / other logic ]
  • on "Delete" click we just delete path and all the secondaryPaths

I think this kind of implementation at least won't break any existent functionality. WDYT?

@guergana
Copy link
Collaborator Author

@guergana @pdelboca As we don't yet have tests for this store, and the complexity is already very high, I think the safest approach here would be to introduce a completely new state property like secondaryPaths with completely separated logic that only works for selection and deleting (the user story requirement), for example:

* on file click we set `path='file1'`

* on ctrl-click on other file we set `secondaryPaths=['file2']`

* [handling selecting / deselecting / other logic ]

* on "Delete" click we just delete `path` and all the `secondaryPaths`

I think this kind of implementation at least won't break any existent functionality. WDYT?

@roll I thought about doing something similar like paths when it was a multiselect and only path for single select, but then also thought this is not a very elegant solution... this is why i went for changing the whole store, but yes, as you point out, this is a very risky approach since we don't have tests throught the application and i might have broken something. I agree your approach is a good solution for now.

@guergana
Copy link
Collaborator Author

@guergana @pdelboca As we don't yet have tests for this store, and the complexity is already very high, I think the safest approach here would be to introduce a completely new state property like secondaryPaths with completely separated logic that only works for selection and deleting (the user story requirement), for example:

* on file click we set `path='file1'`

* on ctrl-click on other file we set `secondaryPaths=['file2']`

* [handling selecting / deselecting / other logic ]

* on "Delete" click we just delete `path` and all the `secondaryPaths`

I think this kind of implementation at least won't break any existent functionality. WDYT?

@roll I am trying to implement your proposed approach but I think it will also complicate the logic. I can't find a way to implement this in a simple way. Would you mind taking over this task and implementing your proposed approach?

@guergana guergana closed this Jun 14, 2024
@guergana
Copy link
Collaborator Author

Finally, @pdelboca s proposed approach worked better and I have implemented it in a different PR. I will close this PR in favor of #426

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem selecting multiple files on the left menu
2 participants